package cw.spring.security.acl.poc.model;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

import org.hibernate.validator.Length;
import org.hibernate.validator.NotNull;
import org.hibernate.validator.Pattern;

@Entity
@Table(name = "Trader", uniqueConstraints = { @UniqueConstraint(columnNames = { "name" }) })
public class TraderModel {

  private long id;
  private String name; // name of the group

  @Id
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  public long getId() {
    return id;
  }

  public void setId(long id) {
    this.id = id;
  }

  @NotNull(message = "The trader name is not optional")
  @Length(min = 1, max = 256, message = "The trader name must have a length superior or equals to 1")
  @Pattern(regex = "[a-zA-Z0-9_\\ ]*", message = "The name must be composed of characters or spaces only (no numbers)")
  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }

}
